class Solution
{
  int count_palindromic_slices(String  s )
  {
      int n = s.length();
      int count = 0;
      for( int p = 0; p < 2; ++p )
      {
          for( int k = n - p - 1; k > 0; --k )
          {
              int qm = Math.min( k, n - k - p );
              int q = 0;
              while( q < qm && s.charAt(k - q - 1) == s.charAt(k + q + p) )
                  ++q;
              count += q;
          }
      }
      return count;
  }
}